/*
 * Copyright (C) 2012-2013  Romain DUBOIS
 * 
 * This file is part of NeMoS - Network and Modular Software
 * 
 * NeMoS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * NeMoS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with NeMoS.  If not, see <http://www.gnu.org/licenses/>.
 */
package nemos.launch.internal;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

import org.osgi.framework.Constants;

/**
 * ELaunchMessage : The NeMoS Launch messages.
 * 
 * @author Romain DUBOIS
 */
public enum ELaunchMessage {
    /** A property is invalid */
    INVALID_PROPERTY("property.error"), //$NON-NLS-1$

    /** The recorder is initialized */
    RECORDER_INITIALIZED("recorder.initialized"), //$NON-NLS-1$

    /** The records have been loaded */
    RECORDS_LOADED("records.load.done"), //$NON-NLS-1$
    /** The records could not be loaded */
    UNABLE_TO_LOAD_RECORDS("records.load.error"), //$NON-NLS-1$
    /** Launch data have been added to the records */
    LAUNCH_DATA_RECORDED("records.save.done"), //$NON-NLS-1$
    /** The records could not be saved */
    UNABLE_TO_SAVE_RECORDS("records.save.error"), //$NON-NLS-1$

    /** A new start level has been reached */
    START_LEVEL_REACHED("startLevel.reached"); //$NON-NLS-1$

    /** The message key */
    private String mKey;

    /**
     * Constructor.
     * 
     * @param pKey
     *            The message key
     */
    private ELaunchMessage(final String pKey) {
        mKey = pKey;
    }

    /**
     * Get the localized message.
     * 
     * @param pParams
     *            The message parameters
     * @return The localized message
     */
    public String getMessage(final Object... pParams) {
        final ResourceBundle lTranslator = ResourceBundle.getBundle(
                Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME, Locale.getDefault(), getClass()
                        .getClassLoader());
        return MessageFormat.format(lTranslator.getString(mKey), pParams);
    }
}
